Skip to main content

Gaussian clouds

Clouds using Gaussian noise

This is a 2D Gaussian random field with a 1/k21/k^2 spectrum and linear dispersion ωk\omega \propto k. I clip the field to positive values and square root it to give an edge to the "clouds".

Adapted from https://mathematica.stackexchange.com/questions/80486/generating-animations-of-clouds-with-mathematica

Download original notebook
n = 256;
k2 = Outer[Plus, #, #] &[RotateRight[N@Range[-n, n - 1, 2]/n, n/2]^2];

spectrum = With[{d := RandomReal[NormalDistribution[], {n, n}]},
   (1/n) (d + I d)/(0.000001 + k2)]; 
spectrum[[1, 1]] *= 0;

im[p_] := Clip[Re[InverseFourier[spectrum Exp[I p]]], {0, ∞}]^0.5

p0 = p = Sqrt[k2];

Animate

EventHandler["frame",
  Function[Null, buffer = NumericArray[255.0 im[p0 += p], "UnsignedInteger8", "ClipAndRound"]]
];

EventFire["frame", True];

Image[
  buffer // Offload, "Byte",
  Epilog -> {
    AnimationFrameListener[buffer // Offload, "Event" -> "frame"]
  }, Magnification -> 2
]
(*VB[*)(FrontEndRef["30bafec7-00b4-423e-a80b-b78471f18e0e"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKGxskJaalJpvrGhgkmeiaGBmn6iZaGCTpJplbmJgbphlapBqkAgCJfhXD"*)(*]VB*)